/**
 * long description for the file
 *
 * @summary short description for the file
 * @author xuesheng zhang
 *
 * Created at     : 2018-08-30 09:14:04 
 * Last modified  : 2019-01-14 10:00:57
 */

import moment from 'moment';

const TimeMatter = (val, type = 0) => {
    if (!val) { return '---'; };
    if (type == 'date') {
        return moment(val).format('YYYY-MM-DD')
    } else if (type == 'time') {
        return moment(val).format('HH:mm:ss')
    } else if (type == 'timer') {
        return moment(val).format('HH:mm')
    } else {
        return moment(val).format('YYYY-MM-DD HH:mm:ss')
    }
}

const FileterTime = (val) => {
    return TimeMatter(val, "timer")
}

const FileterDateTime = (val) => {
    return TimeMatter(val, "000")
}

const FileterDate = (val) => {
    return TimeMatter(val, "date")
}

const FormatMobile = (val) => {
    debugger
    if (val) {
        let mobile = val.substr(0, 3) + "****" + val.substr(-4);
        return mobile;
    } else {
        return val;
    }

}

export default { FileterTime, FileterDateTime, FormatMobile, FileterDate }